package com.sp2p.action.front;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLDecoder;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.imageio.ImageIO;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;

import com.sp2p.service.BorrowService;
import com.sp2p.constants.IAmountConstants;
import com.shove.Convert;
import com.shove.data.DataException;
import com.shove.util.SqlInfusion;
import com.shove.web.Request;
import com.shove.web.util.JSONUtils;
import com.sp2p.constants.IConstants;
import com.sp2p.database.Dao.Views.intentionfund_user;
import com.sp2p.entity.User;
import com.sp2p.service.AssignmentDebtService;
import com.sp2p.service.FinanceService;
import com.sp2p.service.GoFullAwardService;
import com.sp2p.service.HomeInfoSettingService;
import com.sp2p.service.MyHomeService;
import com.sp2p.service.NewsAndMediaReportService;
import com.sp2p.service.PublicModelService;
import com.sp2p.service.SelectedService;
import com.sp2p.service.UserService;
import com.sp2p.service.admin.BorrowManageService;
import com.sp2p.service.admin.PlatformCostService;
import com.sp2p.service.admin.ShoveBorrowTypeService;
import com.sp2p.util.AmountUtil;
import com.sp2p.util.DateUtil;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;



/**
 * @ClassName: FrontMyFinanceAction.java
 * @Author: gang.lv
 * @Date: 2013-3-4 上午11:16:33
 * @Copyright: 2013 www.emis.com Inc. All rights reserved.
 * @Version: V1.0.1
 * @Descrb: 我的理财控制层
 */
public class FrontMyFinanceAction extends BaseFrontAction {

	public static Log log = LogFactory.getLog(FrontMyFinanceAction.class);
	private static final long serialVersionUID = 1L;

	private FinanceService financeService;
	private SelectedService selectedService;
	private Map<String, String> investDetailMap;
	private NewsAndMediaReportService newsService;
	private ShoveBorrowTypeService  shoveBorrowTypeService;
	private PublicModelService publicModelService;
	private HomeInfoSettingService homeInfoSettingService;
	private PlatformCostService platformCostService;
	private UserService userService;
	 
	//--
	private BorrowService borrowService;
	private BorrowManageService  borrowManageService;
	//--
	private List<Map<String, Object>> borrowMSGMap;
	
	private List<Map<String, Object>> borrowPurposeList ;
    private List<Map<String, Object>> borrowDeadlineList ;
    private List<Map<String, Object>> borrowAmountList ;
    private List<Map<String, Object>> linksList;
    private List<Map<String, Object>> meikuList;
    private List<Map<String, Object>> meikuStick;
    private List<Map<String, Object>> listsGGList;
    private List<Map<String, Object>> bannerList;
   
    private MyHomeService myHomeService; 
    private GoFullAwardService goFullAwardService;
    	
	public void setGoFullAwardService(GoFullAwardService goFullAwardService) {
		this.goFullAwardService = goFullAwardService;
	}
	
	public void setPlatformCostService(PlatformCostService platformCostService) {
		this.platformCostService = platformCostService;
	}


	/**
	 * @Return:
	 * @Descb: 稳盈宝列表
	 * @Throws:
	 */
	public String wybListPage() throws Exception {
		pageBean.setPageNum(request().getParameter("PAGE_NO_KEY"));
		pageBean.setPageSize(IConstants.PAGE_SIZE_10);
		
		try {
			financeService.queryLastestBorrowPage(pageBean);
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			return "network";
		}
		request().setAttribute("wybList", pageBean.getPage());
		request().setAttribute("currentPage", pageBean.getPageNum());
		request().setAttribute("totalPageNum", pageBean.getTotalPageNum());
		return SUCCESS;
	}
	
	/**
	 * @Return:
	 * @Descb: 新手专享列表
	 * @Throws:
	 */
	public String xsLoansPage() throws Exception {
		pageBean.setPageNum(request().getParameter("PAGE_NO_KEY"));
		pageBean.setPageSize(IConstants.PAGE_SIZE_10);
		
		try {
			financeService.queryLastestXsBorrowPage(pageBean);
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			return "network";
		}
		request().setAttribute("xsLoans", pageBean.getPage());
		request().setAttribute("currentPage", pageBean.getPageNum());
		request().setAttribute("totalPageNum", pageBean.getTotalPageNum());
		return SUCCESS;
	}
	
	/**
	 * @Return:
	 * @Descb: 债权列表
	 * @Throws:
	 */
	public String debtListPage() throws Exception {
		pageBean.setPageNum(request().getParameter("PAGE_NO_KEY"));
		pageBean.setPageSize(IConstants.PAGE_SIZE_10);
		
		try {
			financeService.queryLastestDebtPage(pageBean);
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			return "network";
		}
		request().setAttribute("debtList", pageBean.getPage());
		request().setAttribute("currentPage", pageBean.getPageNum());
		request().setAttribute("totalPageNum", pageBean.getTotalPageNum());
		return SUCCESS;
	}
	
	/**
	 * @Date: 2013-3-18 下午01:46:12
	 * @Return:
	 * @Descb: 首页加载内容
	 * @Throws:
	 */
	public String index() throws Exception {
		//是否保存登录状态
		try{
			User u=(User) session().getAttribute("user");
			if(u==null){
			    Cookie[] cookies=request().getCookies();
			    if(cookies!=null){
			    	String name = "";
					String password = "";
					String source="";
					boolean flag=false; //判断cookie中是否含有cookie_user;
				    for(int i=0;i<cookies.length;i++){
				        if(cookies[i].getName().equals("cookie_user")){
				        	String value =  URLDecoder.decode(cookies[i].getValue(),"utf-8");
					        if(value!=null&&!"".equals(value)){
					            name=value.split("-")[0];
					            source=value.split("-")[2];
					            if(value.split("-")[1]!=null && !value.split("-")[1].equals("null")){
					               password=value.split("-")[1];
					               flag=true;
					            }
					         }
				         }
				    }
				    if(flag){
				    	User user=new User();
					    user.setUserName(name);
					    user.setPassword(password);
					    user.setSource(Convert.strToInt(source, -1));
					    if(user.getUserName().equals("")){
					    	user.setId(null);
					    }else{
					    	Map<String,String> map = userService.getUserByNameAPwd(user.getUserName());
						    if(map!=null&&map.get("id")!=null&&map.size()!=0){
						    	user.setId(Long.parseLong(map.get("id")));
						    	if(!map.get("password").equals(user.getPassword())){
						    		return "login";
						    	}
						    	Map<String,String> userMap = userService.queryUserById(Long.parseLong(map.get("id")));
						    	user.setEmail(userMap.get("email"));
						    	user.setLastIP(userMap.get("lastIP"));
						    	user.setVipStatus(Integer.parseInt(userMap.get("vipStatus")));
						    	user.setPassword(userMap.get("password"));
						    	user.setAuthStep(Integer.parseInt(userMap.get("authStep")));
						    	user.setEnable(Integer.parseInt(userMap.get("enable")));
						    }
					    }
					    session().setAttribute("user", user);
				    }
			    }
		    }
			else{
				session().setAttribute("user", u);
			}
		}catch(Exception e){
		    e.printStackTrace();
		} 
		//余额宝列表
		Map<String,String> yebMap = financeService.queryBorrowProduct(1);
		Map<String,String> yebAnnualRate = financeService.queryYebAnnualRate();
		request().setAttribute("yebMap", yebMap);
		request().setAttribute("yebAnnualRate", yebAnnualRate.get("annualRate"));
		//月利宝列表
		Map<String,String> ylbMap = financeService.queryBorrowProduct(2);
		request().setAttribute("ylbMap", ylbMap);
		//季发宝列表
		Map<String,String> jfbMap = financeService.queryBorrowProduct(3);
		request().setAttribute("jfbMap", jfbMap);
		
        //稳盈宝列表
		List<Map<String, Object>> mapList = financeService.queryLastestBorrow();
		request().setAttribute("mapList", mapList);
		
		//金融联项目列表
		List<Map<String, Object>> jrlList = financeService.queryJrlLastestBorrow();
		request().setAttribute("jrlList", jrlList);
		
		//债权列表
		List<Map<String, Object>> debtMapList = financeService.queryLastestDebt();
		request().setAttribute("debtMapList", debtMapList);
		
		//新手专享列表
		List<Map<String, Object>> xsMapList = financeService.queryLastestNewUserBorrow();
		request().setAttribute("xsMap", xsMapList);

		// 理财风云榜，前5条记录
		List<Map<String, Object>> rankList = financeService.get_topNInvestment(5);
		request().setAttribute("rankList",rankList);
		// 本月新人王，前5条记录
		List<Map<String, Object>> mothRankList = financeService.get_mothTopNInvestment(5);
		request().setAttribute("mothRankList",mothRankList);
		
		//公告
		List<Map<String,Object>> newsList = new ArrayList<Map<String,Object>>();
		pageBean.setPageSize(4);
		newsService.frontQueryNewsPage(pageBean);
		newsList = pageBean.getPage();
		pageBean.setPage(null);
		request().setAttribute("newsList", newsList);

		//友情链接
		pageBean.setPageSize(100);
		publicModelService.queryLinksPage(pageBean);
		linksList =pageBean.getPage();
		pageBean.setPage(null);
		request().setAttribute("linksList", linksList);
		//媒体报道 取4条记录
		pageBean.setPageSize(4);
		newsService.queryMediaReportPage(pageBean);		
		meikuList = pageBean.getPage();
		pageBean.setPage(null);
		request().setAttribute("meikuList", meikuList);
		//图片滚动
		pageBean.setPageSize(7);
		publicModelService.queryBannerListPage(pageBean);
		bannerList =pageBean.getPage();
		pageBean.setPage(null);
		request().setAttribute("bannerList", bannerList);
		
		//总投资用户数
		Map<String,String> userCountMap = userService.queryUserCount();	
		request().setAttribute("userCount", userCountMap.get("nums"));
		//随心投用户数
		Map<String, String> sxtUserCountMap = userService.querySxtUserCount();
		request().setAttribute("sxtUserCount", sxtUserCountMap.get("nums"));
		//稳盈宝用户数
		Map<String, String> wybUserCountMap = userService.queryWybUserCount();
		request().setAttribute("wybUserCount", wybUserCountMap.get("nums"));
		//投资总额
		Map<String,String> financeEarnMap = financeService.queryTotalInvest();
		request().setAttribute("investAmount", financeEarnMap.get("totalInvestAmount"));
		//随心投投资额
		Map<String,String> sxtFinanceEarnMap = financeService.querySxtTotalInvest();
		request().setAttribute("sxtInvestAmount", sxtFinanceEarnMap.get("totalInvestAmount"));
		//稳盈宝投资额
		Map<String,String> wybFinanceEarnMap = financeService.queryWybTotalInvest();
		request().setAttribute("wybInvestAmount", wybFinanceEarnMap.get("totalInvestAmount"));
		
		//得到用户对象
		User user = (User) session().getAttribute("user");
		if (user!=null) {
			paramMap = userService.queryUserById(user.getId());
		}
		return "success";
	}

	/**
	 * @throws DataException
	 * @throws SQLException
	 * @MethodName: index
	 * @Param: FrontMyFinanceAction
	 * @Author: xuzhaojun
	 * @Date: 2014-06-03
	 * @Return:
	 * @Descb: 我要投资加载内容
	 * @Throws:
	 */
	public String investIndex() throws Exception {
		//余额宝列表
		Map<String,String> yebMap = financeService.queryBorrowProduct(1);
		Map<String,String> yebAnnualRate = financeService.queryYebAnnualRate();
		request().setAttribute("yebMap", yebMap);
		request().setAttribute("yebAnnualRate", yebAnnualRate.get("annualRate"));
		//月利宝列表
		Map<String,String> ylbMap = financeService.queryBorrowProduct(2);
		request().setAttribute("ylbMap", ylbMap);
		//季发宝列表
		Map<String,String> jfbMap = financeService.queryBorrowProduct(3);
		request().setAttribute("jfbMap", jfbMap);
		//稳赢宝列表
		pageBean.setPageNum(1);
		pageBean.setPageSize(5);
		financeService.queryLastestBorrowPage(pageBean);
		request().setAttribute("mapList", pageBean.getPage());

		return "success";
	}	
	
	public String debtDetail()  throws Exception {
		User user = (User) session().getAttribute("user");
		if(user != null){
			Map<String, String> accmountStatisMap = userService.queryUserById(user.getId());
			request().setAttribute("accmountStatisMap", accmountStatisMap);
		}
		
		String idStr =SqlInfusion.FilteSqlInfusion( request().getParameter("id") == null ? "" : request().getParameter("id"));
		if (!"".equals(idStr) && StringUtils.isNumericSpace(idStr)) {
			//债权详情
			long debtId = Convert.strToLong(idStr, -1);
			Map<String, String> debtDetailMap = financeService.queryDebtDetailById(debtId);
			
			if (debtDetailMap != null && debtDetailMap.size() > 0) {
				request().setAttribute("debtDetailMap", debtDetailMap);
				
				long borrowId = Convert.strToLong(debtDetailMap.get("parentBId"), -1);
				// 借款人资料
				Map<String, String> borrowUserMap = financeService.queryUserInfoById(borrowId);
				request().setAttribute("borrowUserMap", borrowUserMap);
				
				//借款记录
				Map<String,String> borrowRecordMap = financeService.queryBorrowRecord(borrowId);
				request().setAttribute("borrowRecordMap", borrowRecordMap);
				
				//担保公司资料
				long agent = Convert.strToLong(debtDetailMap.get("agent"), -1);
				Map<String,String> agentMap = financeService.getBorrowAgentByAgentId(agent);
				request().setAttribute("agentMap", agentMap);
				//信息披露
				List<Map<String, Object>> infodisclosureList = financeService.getInfodisclosureList(borrowId);
				request().setAttribute("infodisclosureList", infodisclosureList);
				
			}
		}
		
		return SUCCESS;
	}
	
	public String xsLoanDetail()  throws Exception {
		User user = (User) session().getAttribute("user");
		if(user != null){
			Map<String, String> accmountStatisMap = myHomeService.queryAvailableElite(user.getId());
			request().setAttribute("accmountStatisMap", accmountStatisMap);
		}
		
		String idStr =SqlInfusion.FilteSqlInfusion( request().getParameter("id") == null ? "" : request().getParameter("id"));
		if (!"".equals(idStr) && StringUtils.isNumericSpace(idStr)) {
			Long id = Convert.strToLong(idStr, -1);
			// 借款详细
			Map<String, String> borrowDetailMap = financeService.queryBorrowDetail(id,4,1);
			
			if (borrowDetailMap != null && borrowDetailMap.size() > 0) {
				//借款详细
				request().setAttribute("borrowDetailMap", borrowDetailMap);
				//收益详情
				double borrowSum = Convert.strToDouble(borrowDetailMap.get("borrowSum")+"", 0);
				double investAmount = borrowSum;
				double annualRate = Convert.strToDouble(borrowDetailMap.get("annualRate")+"", 0);
				int deadline = Convert.strToInt(borrowDetailMap.get("deadline")+"", 0);
				int paymentMode = Convert.strToInt(borrowDetailMap.get("paymentMode")+"", -1);
				int isDayThe = Convert.strToInt(borrowDetailMap.get("isDayThe")+"", 1);
				
				AmountUtil au = new AmountUtil();
				Map<String,String> earnMap = null;
				String earnAmount = "";
				if(paymentMode == 1){
					//按月等额还款
					earnMap = au.earnCalculateMonth(investAmount, borrowSum, annualRate, deadline, 0, isDayThe, 2,0);
					earnAmount = earnMap.get("msg")+"";
				}else if(paymentMode == 2){
					//先息后本
					earnMap = au.earnCalculateSum(investAmount, borrowSum, annualRate, deadline, 0, isDayThe, 2);
					earnAmount = earnMap.get("msg")+"";
				} else if (paymentMode == 4) {
					// 一次性还款
					earnMap = au.earnCalculateOne(investAmount, borrowSum,annualRate, deadline, 0, isDayThe, 2, 0);
					earnAmount = earnMap.get("msg") + "";
				}
				double monInterest = Convert.strToDouble(earnMap.get("monInterest"),0);
				DecimalFormat   df   =   new   DecimalFormat("#####0.00");
				request().setAttribute("monInterest", df.format(monInterest));
				
				
				// 借款人资料
				Map<String, String> borrowUserMap = financeService.queryUserInfoById(id);
				request().setAttribute("borrowUserMap", borrowUserMap);
				
				//借款记录
				Map<String,String> borrowRecordMap = financeService.queryBorrowRecord(id);
				request().setAttribute("borrowRecordMap", borrowRecordMap);
				
				//担保公司资料
				long agent = Convert.strToLong(borrowDetailMap.get("agent"), -1);
				Map<String,String> agentMap = financeService.getBorrowAgentByAgentId(agent);
				request().setAttribute("agentMap", agentMap);
				
				//信息披露
				List<Map<String, Object>> infodisclosureList = financeService.getInfodisclosureList(id);
				request().setAttribute("infodisclosureList", infodisclosureList);
				
				// 每次点击借款详情时新增浏览量
				financeService.addBrowseCount(id);

			} else {
				return "404";
			}
		} else {
			return "404";
		}
		return "success";
	}
	
	public String wybDetail()  throws Exception {
		User user = (User) session().getAttribute("user");
		if(user != null){
			Map<String, String> accmountStatisMap = userService.queryUserById(user.getId());
			request().setAttribute("accmountStatisMap", accmountStatisMap);
			//可用共富券
			int voucherType = 1; //抵用券
			List<Map<String, Object>> availableVoucherList = financeService.queryAvailableVoucherList(user.getId(),voucherType);
			request().setAttribute("availableVoucherList", availableVoucherList);
		}
		
		String idStr =SqlInfusion.FilteSqlInfusion( request().getParameter("id") == null ? "" : request().getParameter("id"));
		if (!"".equals(idStr) && StringUtils.isNumericSpace(idStr)) {
			Long id = Convert.strToLong(idStr, -1);
			// 借款详细
			Map<String, String> borrowDetailMap = financeService.queryBorrowDetail(id,4,0);
			
			if (borrowDetailMap != null && borrowDetailMap.size() > 0) {
				//借款详细
				request().setAttribute("borrowDetailMap", borrowDetailMap);
				//收益详情
				double borrowSum = Convert.strToDouble(borrowDetailMap.get("borrowSum")+"", 0);
				double investAmount = borrowSum;
				double annualRate = Convert.strToDouble(borrowDetailMap.get("annualRate")+"", 0);
				int deadline = Convert.strToInt(borrowDetailMap.get("deadline")+"", 0);
				int paymentMode = Convert.strToInt(borrowDetailMap.get("paymentMode")+"", -1);
				int isDayThe = Convert.strToInt(borrowDetailMap.get("isDayThe")+"", 1);
				
				AmountUtil au = new AmountUtil();
				Map<String,String> earnMap = null;
				String earnAmount = "";
				if(paymentMode == 1){
					//按月等额还款
					earnMap = au.earnCalculateMonth(investAmount, borrowSum, annualRate, deadline, 0, isDayThe, 2,0);
					earnAmount = earnMap.get("msg")+"";
				}else if(paymentMode == 2){
					//先息后本
					earnMap = au.earnCalculateSum(investAmount, borrowSum, annualRate, deadline, 0, isDayThe, 2);
					earnAmount = earnMap.get("msg")+"";
				} else if (paymentMode == 4) {
					// 一次性还款
					earnMap = au.earnCalculateOne(investAmount, borrowSum,annualRate, deadline, 0, isDayThe, 2, 0);
					earnAmount = earnMap.get("msg") + "";
				}
				double monInterest = Convert.strToDouble(earnMap.get("monInterest"),0);
				DecimalFormat   df   =   new   DecimalFormat("#####0.00");
				request().setAttribute("monInterest", df.format(monInterest));
				
				
				// 借款人资料
				Map<String, String> borrowUserMap = financeService.queryUserInfoById(id);
				request().setAttribute("borrowUserMap", borrowUserMap);
				
				//借款记录
				Map<String,String> borrowRecordMap = financeService.queryBorrowRecord(id);
				request().setAttribute("borrowRecordMap", borrowRecordMap);
				
				//担保公司资料
				long agent = Convert.strToLong(borrowDetailMap.get("agent"), -1);
				Map<String,String> agentMap = financeService.getBorrowAgentByAgentId(agent);
				request().setAttribute("agentMap", agentMap);
				
				//信息披露
				List<Map<String, Object>> infodisclosureList = financeService.getInfodisclosureList(id);
				request().setAttribute("infodisclosureList", infodisclosureList);
				// 每次点击借款详情时新增浏览量
				financeService.addBrowseCount(id);
				
			} else {
				return "404";
			}
		} else {
			return "404";
		}
		
		return "success";
	}
	
	public String yebDetail()  throws Exception {
		User user = (User) session().getAttribute("user");
		if(user != null){
			Map<String, String> accmountStatisMap = userService.queryUserById(user.getId());
			request().setAttribute("accmountStatisMap", accmountStatisMap);
		}
		
		String idStr =SqlInfusion.FilteSqlInfusion(request().getParameter("pid") == null ? "" : request()
				.getParameter("pid"));
		if (!"".equals(idStr) && StringUtils.isNumericSpace(idStr)) {
			Long id = Convert.strToLong(idStr, -1);
			Map<String, String> productDetailMap = financeService.queryProductDetailById(id,1);
			
			String publishTime = productDetailMap.get("publishTime");
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String remainTimeEnd = df.format(DateUtil.dateAddDay(DateUtil.strToDate(publishTime), 3));
			productDetailMap.put("remainTimeEnd", remainTimeEnd);
			
			Map<String,String> yebAnnualRate = financeService.queryYebAnnualRate();
			productDetailMap.put("yebAnnualRate", yebAnnualRate.get("annualRate"));
			
			request().setAttribute("productDetailMap", productDetailMap);
			//根据产品Id查询披露信息
			List<Map<String, Object>> infodisclosureList = financeService.getInfodisclosureListByPid(id);
			request().setAttribute("infodisclosureList", infodisclosureList);
		}
		
		return SUCCESS;
	}
	
	public String ylbDetail()  throws Exception {
		User user = (User) session().getAttribute("user");
		if(user != null){
			Map<String, String> accmountStatisMap = userService.queryUserById(user.getId());
			request().setAttribute("accmountStatisMap", accmountStatisMap);
		}
		
		String idStr =SqlInfusion.FilteSqlInfusion(request().getParameter("pid") == null ? "" : request()
				.getParameter("pid"));
		if (!"".equals(idStr) && StringUtils.isNumericSpace(idStr)) {
			Long id = Convert.strToLong(idStr, -1);
			Map<String, String> productDetailMap = financeService.queryProductDetailById(id,2);
			String publishTime = productDetailMap.get("publishTime");
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String remainTimeEnd = df.format(DateUtil.dateAddDay(DateUtil.strToDate(publishTime), 3));//加入期限
			String repayTimeEnd = df.format(DateUtil.dateAddMonth(DateUtil.strToDate(publishTime), 1));//到期日
			productDetailMap.put("remainTimeEnd", remainTimeEnd);
			productDetailMap.put("repayTimeEnd", repayTimeEnd);
			request().setAttribute("productDetailMap", productDetailMap);
			//根据产品Id查询披露信息
			List<Map<String, Object>> infodisclosureList = financeService.getInfodisclosureListByPid(id);
			request().setAttribute("infodisclosureList", infodisclosureList);
			//可用共富券
			int voucherType = 1; //抵用券
			List<Map<String, Object>> availableVoucherList = financeService.queryAvailableVoucherList(user.getId(),voucherType);
			request().setAttribute("availableVoucherList", availableVoucherList);
		}

		return SUCCESS;
	}
	
	
	public String jfbDetail()  throws Exception {
		User user = (User) session().getAttribute("user");
		if(user != null){
			Map<String, String> accmountStatisMap = userService.queryUserById(user.getId());
			request().setAttribute("accmountStatisMap", accmountStatisMap);
		}
		
		String idStr =SqlInfusion.FilteSqlInfusion(request().getParameter("pid") == null ? "" : request()
				.getParameter("pid"));
		if (!"".equals(idStr) && StringUtils.isNumericSpace(idStr)) {
			Long id = Convert.strToLong(idStr, -1);
			Map<String, String> productDetailMap = financeService.queryProductDetailById(id,3);
			String publishTime = productDetailMap.get("publishTime");
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String remainTimeEnd = df.format(DateUtil.dateAddDay(DateUtil.strToDate(publishTime), 3));
			String repayTimeEnd = df.format(DateUtil.dateAddMonth(DateUtil.strToDate(publishTime), 3));//到期日
			productDetailMap.put("remainTimeEnd", remainTimeEnd);
			productDetailMap.put("repayTimeEnd", repayTimeEnd);
			request().setAttribute("productDetailMap", productDetailMap);
			//根据产品Id查询披露信息
			List<Map<String, Object>> infodisclosureList = financeService.getInfodisclosureListByPid(id);
			request().setAttribute("infodisclosureList", infodisclosureList);
			//可用共富券
			int voucherType = 1; //抵用券
			List<Map<String, Object>> availableVoucherList = financeService.queryAvailableVoucherList(user.getId(),voucherType);
			request().setAttribute("availableVoucherList", availableVoucherList);
		}
		
		return SUCCESS;
	}
	
	
	public void queryInvestBybId()  throws Exception {
		String idStr =SqlInfusion.FilteSqlInfusion( paramMap.get("id") == null ? "" : paramMap.get("id"));
		Long id = Convert.strToLong(idStr, -1);
		String curPage =SqlInfusion.FilteSqlInfusion( paramMap.get("curPage") == null ? "" : paramMap.get("curPage"));
		
		pageBean.setPageNum(curPage);
		pageBean.setPageSize(IConstants.PAGE_SIZE_10);
		// 投资记录		
		financeService.queryInvestBybId(id,pageBean);
		
		JSONObject obj = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		obj.put("voList", JSONUtils.toJSONArray(pageBean.getPage()));
		obj.put("currentPage", curPage);
		obj.put("pageCount", pageBean.getTotalPageNum());
		obj.put("totalNum", pageBean.getTotalNum());
		JSONUtils.printObject(obj);
	}
	
	public void queryYebInvestBypId()  throws Exception {
		String idStr =SqlInfusion.FilteSqlInfusion( paramMap.get("id") == null ? "" : paramMap.get("id"));
		Long id = Convert.strToLong(idStr, -1);
		String curPage =SqlInfusion.FilteSqlInfusion( paramMap.get("curPage") == null ? "" : paramMap.get("curPage"));
		
		pageBean.setPageNum(curPage);
		pageBean.setPageSize(IConstants.PAGE_SIZE_10);
		// 投资记录		
		financeService.queryYebInvestBypId(id,pageBean);
		
		JSONObject obj = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		obj.put("voList", JSONUtils.toJSONArray(pageBean.getPage()));
		obj.put("currentPage", curPage);
		obj.put("pageCount", pageBean.getTotalPageNum());
		obj.put("totalNum", pageBean.getTotalNum());
		JSONUtils.printObject(obj);
	}
	
	public void queryInvestBypId()  throws Exception {
		String idStr =SqlInfusion.FilteSqlInfusion( paramMap.get("id") == null ? "" : paramMap.get("id"));
		Long id = Convert.strToLong(idStr, -1);
		String curPage =SqlInfusion.FilteSqlInfusion( paramMap.get("curPage") == null ? "" : paramMap.get("curPage"));
		
		pageBean.setPageNum(curPage);
		pageBean.setPageSize(IConstants.PAGE_SIZE_10);
		// 投资记录		
		financeService.queryInvestBypId(id,pageBean);
		
		JSONObject obj = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		obj.put("voList", JSONUtils.toJSONArray(pageBean.getPage()));
		obj.put("currentPage", curPage);
		obj.put("pageCount", pageBean.getTotalPageNum());
		obj.put("totalNum", pageBean.getTotalNum());
		JSONUtils.printObject(obj);
	}
	
	public void yebFinanceInvest()throws Exception{
		User user = (User) session().getAttribute("user");
	    JSONObject obj = new JSONObject();
		
	    String pid = SqlInfusion.FilteSqlInfusion(paramMap.get("pid") == null?"":paramMap.get("pid"));
		long pidLong = Convert.strToLong(pid, -1);
		
		String amount = SqlInfusion.FilteSqlInfusion(paramMap.get("amount") == null?"":paramMap.get("amount"));
		double amountDouble = Convert.strToDouble(amount, 0);
	    
	    String pageId =SqlInfusion.FilteSqlInfusion( paramMap.get("pageId"));
//	    String code = (String) session().getAttribute(pageId + "_checkCode");
//		String _code = SqlInfusion.FilteSqlInfusion(paramMap.get("code").toString().trim());
//		if (code == null || !_code.equals(code)) {
//			obj.put("msg", "验证码错误");
//			JSONUtils.printObject(obj);
//			return;
//		}
		
		Map<String,String> result = financeService.addYebProductBorrowInvest(pidLong, user.getId(), amountDouble,getBasePath(),user.getUserName());
	    int ret = Convert.strToInt(result.get("ret"), -1);
		String resultMSG = result.get("ret_desc");
	    if(ret > 0){
			obj.put("result", "success");
			obj.put("msg", resultMSG);
	    }else{
	    	obj.put("msg", resultMSG);
	    }
		
		JSONUtils.printObject(obj);
	}

	public void ylbFinanceInvest()throws Exception{
		User user = (User) session().getAttribute("user");
	    JSONObject obj = new JSONObject();
	    
	    String voucherId = SqlInfusion.FilteSqlInfusion(paramMap.get("voucherId") == null?"":paramMap.get("voucherId"));
		long voucherIdLong = Convert.strToLong(voucherId, -1);
		
	    String pid = SqlInfusion.FilteSqlInfusion(paramMap.get("pid") == null?"":paramMap.get("pid"));
		long pidLong = Convert.strToLong(pid, -1);
		
		String amount = SqlInfusion.FilteSqlInfusion(paramMap.get("amount") == null?"":paramMap.get("amount"));
		double amountDouble = Convert.strToDouble(amount, 0);
	    
	    String pageId =SqlInfusion.FilteSqlInfusion( paramMap.get("pageId"));
//	    String code = (String) session().getAttribute(pageId + "_checkCode");
//		String _code = SqlInfusion.FilteSqlInfusion(paramMap.get("code").toString().trim());
//		if (code == null || !_code.equals(code)) {
//			obj.put("msg", "验证码错误");
//			JSONUtils.printObject(obj);
//			return;
//		}
		
		int ptype = 2; //产品类型(1：余额宝  2：月利宝  3：季发宝)
		int profitDisposal = 0; //收益方式(0：不处理   1：收益复投   2:收益返还)
		
		//添加月利宝投资记录
		Map<String,String> result = financeService.addProductBorrowInvest(pidLong, user
				.getId(), amountDouble,getBasePath(),user.getUserName(),ptype,profitDisposal);
	    String resultMSG = result.get("ret_desc");
	    
	    if("".equals(resultMSG)){
			obj.put("result", "success");
			//使用共富券
			if(voucherIdLong > 0){
				financeService.gofullVoucherReceive(user.getId(), voucherIdLong, pidLong, ptype, amountDouble);
			}
	    }else{
	    	obj.put("msg", result.get("ret_desc")+"");
	    }
		
		JSONUtils.printObject(obj);
	}

	public void jfbFinanceInvest()throws Exception {
		User user = (User) session().getAttribute("user");
	    JSONObject obj = new JSONObject();
		
	    String voucherId = SqlInfusion.FilteSqlInfusion(paramMap.get("voucherId") == null?"":paramMap.get("voucherId"));
		long voucherIdLong = Convert.strToLong(voucherId, -1);
	    
	    String pid = SqlInfusion.FilteSqlInfusion(paramMap.get("pid") == null?"":paramMap.get("pid"));
		long pidLong = Convert.strToLong(pid, -1);
		
		String amount = SqlInfusion.FilteSqlInfusion(paramMap.get("amount") == null?"":paramMap.get("amount"));
		double amountDouble = Convert.strToDouble(amount, 0);
		
	    String pageId =SqlInfusion.FilteSqlInfusion( paramMap.get("pageId"));
//	    String code = (String) session().getAttribute(pageId + "_checkCode");
//		String _code = SqlInfusion.FilteSqlInfusion(paramMap.get("code").toString().trim());
//		if (code == null || !_code.equals(code)) {
//			obj.put("msg", "验证码错误");
//			JSONUtils.printObject(obj);
//			return;
//		}
		
		int ptype = 3; //产品类型(1：余额宝  2：月利宝  3：季发宝)
		//收益方式(0：不处理   1：收益复投   2:收益返还)
		int profitDisposal = Convert.strToInt(paramMap.get("profitDisposal") == null?"":paramMap.get("profitDisposal"), 0);
		
		//投资季发宝投资记录
		Map<String,String> result = financeService.addProductBorrowInvest(pidLong, user
				.getId(), amountDouble,getBasePath(),user.getUserName(),ptype,profitDisposal);
	    String resultMSG = result.get("ret_desc");
	    
	    if("".equals(resultMSG)){
			obj.put("result", "success");
			//使用共富券
			if(voucherIdLong > 0){
				financeService.gofullVoucherReceive(user.getId(), voucherIdLong, pidLong, ptype, amountDouble);
			}
	    }else{
	    	obj.put("msg", result.get("ret_desc")+"");
	    }
		
		JSONUtils.printObject(obj);
	}
	
	public void xsFinanceInvest() throws Exception {
	    User user = (User) session().getAttribute("user");
	    JSONObject obj = new JSONObject();
		
	    String id = SqlInfusion.FilteSqlInfusion(paramMap.get("id") == null?"":paramMap.get("id"));
		long idLong = Convert.strToLong(id, -1);
		
	    String pageId =SqlInfusion.FilteSqlInfusion( paramMap.get("pageId"));
	    String code = (String) session().getAttribute(pageId + "_checkCode");
		String _code = SqlInfusion.FilteSqlInfusion(paramMap.get("code").toString().trim());
		if (code == null || !_code.equals(code)) {
			obj.put("msg", "验证码错误");
			JSONUtils.printObject(obj);
			return;
		}
		
		//可用体验金列表
		List<Map<String, String>> availableEliteList = myHomeService.queryAvailableEliteList(user.getId());
		
		if(null != availableEliteList && availableEliteList.size() > 0){
			for (Map<String, String> map : availableEliteList) {
				long tyjId =  Convert.strToLong(map.get("id"), -1L) ;
				//添加新手专享借款投资记录
			    Map<String,String> result = financeService.addXsBorrowInvest(idLong, user
						.getId(), tyjId,getBasePath(),user.getUserName());
			    String resultMSG = result.get("ret_desc");
			    if("".equals(resultMSG)){
					obj.put("msg", "1");
			    }else{
			    	obj.put("msg", result.get("ret_desc")+"");
			    }
			}
		}
		JSONUtils.printObject(obj);
}
	
	public void financeInvest() throws Exception {
		    User user = (User) session().getAttribute("user");
		    JSONObject obj = new JSONObject();
		    
		    String voucherId = SqlInfusion.FilteSqlInfusion(paramMap.get("voucherId") == null?"":paramMap.get("voucherId"));
			long voucherIdLong = Convert.strToLong(voucherId, -1);
			
		    String id = SqlInfusion.FilteSqlInfusion(paramMap.get("id") == null?"":paramMap.get("id"));
			long idLong = Convert.strToLong(id, -1);
			
			String amount = SqlInfusion.FilteSqlInfusion(paramMap.get("amount") == null?"":paramMap.get("amount"));
			double amountDouble = Convert.strToDouble(amount, 0);
		    
		    String pageId =SqlInfusion.FilteSqlInfusion( paramMap.get("pageId"));
		    
//		    String code = (String) session().getAttribute(pageId + "_checkCode");
//			String _code = SqlInfusion.FilteSqlInfusion(paramMap.get("code").toString().trim());
//			if (code == null || !_code.equals(code)) {
//				obj.put("msg", "验证码错误");
//				JSONUtils.printObject(obj);
//				return;
//			}
			
			//添加稳盈宝借款投资记录
		    Map<String,String> result = financeService.addBorrowInvest(idLong, user
					.getId(), amountDouble,getBasePath(),user.getUserName());
		    String resultMSG = result.get("ret_desc");
		    
		    if("".equals(resultMSG)){
				obj.put("msg", "1");
				//使用共富券
				if(voucherIdLong > 0){
					financeService.gofullVoucherReceive(user.getId(), voucherIdLong, idLong, 4, amountDouble);
				}
		    }else{
		    	obj.put("msg", result.get("ret_desc")+"");
		    }
			
			JSONUtils.printObject(obj);
	}
	
	/**
	 * 稳赢宝投资人填写投资金额时,显示该投资金额下的到期收益
	 * @return
	 */
	public String calculateInvestReceipts(){
		JSONObject obj = new JSONObject();
		DecimalFormat   df   =   new   DecimalFormat("#####0.00");
		double investAmount = Convert.strToDouble(paramMap.get("investAmount")+"", 0);
		double borrowSum = Convert.strToDouble(paramMap.get("borrowSum")+"", 0);
		double annualRate = Convert.strToDouble(paramMap.get("annualRate")+"", 0);
		int deadline = Convert.strToInt(paramMap.get("deadline")+"", 0);
		int paymentMode = Convert.strToInt(paramMap.get("paymentMode")+"", -1);
		int isDayThe = Convert.strToInt(paramMap.get("isDayThe")+"", 1);
		
		String idStr = SqlInfusion.FilteSqlInfusion(request().getParameter("id") == null ? "" : request()
				.getParameter("id"));
		if (!"".equals(idStr) && StringUtils.isNumericSpace(idStr)) {
			Long id = Convert.strToLong(idStr, -1);
			//查询借款信息得到借款时插入的平台收费标准
			Map<String, String> map = new HashMap<String, String>();
			try {
				map = borrowManageService.queryBorrowInfo(id);
				if (map == null) {
					return "404";
				}
				//得到收费标准的json代码
				String feelog = Convert.strToStr(map.get("feelog"), "");
				Map<String,Double> feeMap = (Map<String,Double>)JSONObject.toBean(JSONObject.fromObject(feelog),HashMap.class);
				
				AmountUtil au = new AmountUtil();
				Map<String,String> earnMap = null;
				double costFee = Convert.strToDouble(feeMap.get(IAmountConstants.INVEST_FEE_RATE)+"",0);
				if(paymentMode == 1){
					//按月等额还款
					earnMap = au.earnCalculateMonth(investAmount, borrowSum, annualRate, deadline, 0, isDayThe, 2,costFee);
				}else if(paymentMode == 2){
					//先息后本
					earnMap = au.earnCalculateSum(investAmount, borrowSum, annualRate, deadline, 0, isDayThe, 2);
				}else if(paymentMode == 3){
					//秒还
					earnMap = au.earnSecondsSum(investAmount, borrowSum, annualRate, deadline,0, 2);
				} else if (paymentMode == 4) {
					// 一次性还款
					earnMap = au.earnCalculateOne(investAmount, borrowSum,
							annualRate, deadline, 0, isDayThe, 2, costFee);
				}
				//收益相关信息
				 //格式化保留两位数
				double totalInterest = Convert.strToDouble(earnMap.get("totalInterest"),0);
				obj.put("msg", df.format(totalInterest));
				JSONUtils.printObject(obj);
				request().setAttribute("totalInterest", totalInterest);
				return null;
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return null;
	}
	
	
	public void buyCredit() throws Exception {
	    User user = (User) session().getAttribute("user");
	    JSONObject obj = new JSONObject();
		
	    String id = SqlInfusion.FilteSqlInfusion(paramMap.get("debtId") == null?"":paramMap.get("debtId"));
		long debtId = Convert.strToLong(id, -1);
		
	    String pageId =SqlInfusion.FilteSqlInfusion( paramMap.get("pageId"));
//	    String code = (String) session().getAttribute(pageId + "_checkCode");
//		String _code = SqlInfusion.FilteSqlInfusion(paramMap.get("code").toString().trim());
//		if (code == null || !_code.equals(code)) {
//			obj.put("msg", "验证码错误");
//			JSONUtils.printObject(obj);
//			return;
//		}
		
		//购买债权
		Map<String,String> result = financeService.addDebtInvest(debtId, user.getId());
	    int ret = Convert.strToInt(result.get("ret"), -1);
		String resultMSG = result.get("ret_desc");
	    
	    if(ret > 0){
			obj.put("msg", "success");
	    }else{
	    	obj.put("msg", result.get("ret_desc")+"");
	    }
		
		JSONUtils.printObject(obj);
}
	
	/**
	 * 计算投资金额排行榜TOP50
	 * @return
	 * @throws Exception 
	 * @throws DataException 
	 */
	public void investRankTop50() throws Exception{
		String curPage =SqlInfusion.FilteSqlInfusion( paramMap.get("curPage") == null ? "" : paramMap.get("curPage"));
		int currentPage = Convert.strToInt(curPage, 1);
		int pageSize = IConstants.PAGE_SIZE_10;
		int startRow = (currentPage-1)*10;
		int pageCount;
		/*pageBean.setPageNum(curPage);
		pageBean.setPageSize(IConstants.PAGE_SIZE_10);*/
		//获取投资金额排行榜TOP50
		List<Map<String, Object>> investRankList = financeService.get_topNInvestment(50);
		//计算出页数
		if(investRankList.size() % pageSize == 0){
			pageCount = investRankList.size() / pageSize;
		}else{
			pageCount = investRankList.size() / pageSize + 1;
		}
		List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
		for (int i = startRow; i < startRow+pageSize && i < investRankList.size(); i++) {
			resultList.add(investRankList.get(i));
		}
		
		JSONObject obj = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		obj.put("voList", JSONUtils.toJSONArray(resultList));
		obj.put("currentPage", curPage);
		obj.put("pageCount", pageCount);
		obj.put("totalNum", 50);
		JSONUtils.printObject(obj);
	}
	public void investRankTop7() throws Exception{
		//获取投资金额排行榜TOP7
		List<Map<String, Object>> investRankList = financeService.get_topNInvestment(7);
		JSONObject obj = new JSONObject();
		obj.put("voList", JSONUtils.toJSONArray(investRankList));
		JSONUtils.printObject(obj);
	}
	/**
	 * 计算本月新人王TOP10
	 * @return
	 * @throws Exception 
	 * @throws DataException 
	 */
	public void monthInvestRankTop10() throws Exception{
		//获取本月新人王TOP10
		List<Map<String, Object>> investRankList = financeService.get_mothTopNInvestment(10);
		JSONObject obj = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		obj.put("rankList", JSONUtils.toJSONArray(investRankList));
		JSONUtils.printObject(obj);
	}
	public String frontinvestRankList(){
		return "success";
	}
	public String investSuccess() throws Exception{
		User user = (User) session().getAttribute("user");
		Map<String, String> usableSumMap = userService.queryUserAmount(user.getId());
		user.setUsableSum(Convert.strToDouble(usableSumMap.get("usableSum"), 0.00));
		session().setAttribute("user", user);
		
		//自动投资开启状态
//		Map<String, String> automaticBidMap = myHomeService.queryAutomaticBid(user.getId());
//		request().setAttribute("automaticBidMap", automaticBidMap);
//		
//		String productType = Convert.strToStr(request("type"), "");
//		if(productType.equals("yeb")){
//			return "successYeb";
//		}
		return "success";
	}
	
	
	/**
	 * 获取该标的的担保公司信息
	 * @return
	 * @throws Exception
	 */
	public String toAgentConpany()throws Exception{
		long agentId =Convert.strToLong(request().getParameter("agentId"),-1L) ;
		Map<String, String> agentMap = new HashMap<String, String>();
		if(agentId > 0){
			agentMap = financeService.getBorrowAgentByAgentId(agentId);
			if(agentMap != null && agentMap.size() > 0){
				if(null!=agentMap.get("image")&&!(agentMap.get("image").length()>0)){
					agentMap.put("image", agentMap.get("image").substring(3));
				}
				request().setAttribute("agentMap", agentMap);
				return SUCCESS;
			}
		}
		return null;
	}
	public String platform(){
		return SUCCESS;
	}
	/**
	 * 统计数据
	 * @return
	 * @throws Exception 
	 * @throws DataException 
	 */
	public void platformStatistics() throws Exception{
		JSONObject obj = new JSONObject();
		//总投资用户数
		Map<String,String> userCountMap = userService.queryUserCount();	
		obj.put("totalInvestor", userCountMap.get("nums"));
		//投资总额
		Map<String,String> financeEarnMap = financeService.queryTotalInvest();
		obj.put("totalVolume", financeEarnMap.get("totalInvestAmount"));
		//用户总收益
		obj.put("totalInterest", financeEarnMap.get("totalRecievedInterest"));
		Map<String, String> businessUserCount = userService.queryBusinessUserCount();
		obj.put("businessOwnersCount", businessUserCount.get("nums"));
		Map<String, String> wageUserCount = userService.queryWageUserCount();
		obj.put("wageEarnerCount", wageUserCount.get("nums"));
		//满标时间
		Map<String, String> avgLoanFullTimeInSeconds = financeService.avgLoanFullTimeInSeconds();
		obj.put("avgLoanFullTimeInSeconds", avgLoanFullTimeInSeconds.get("avgTime"));
		//转让时间
		Map<String, String> avgCreditRightsSoldTimeInSeconds = financeService.avgCreditRightsSoldTimeInSeconds();
		obj.put("avgCreditRightsSoldTimeInSeconds", avgCreditRightsSoldTimeInSeconds.get("avgTime"));
		JSONUtils.printObject(obj);
	}
	/**
	 * 借款地域分布
	 * @return
	 * @throws Exception 
	 * @throws DataException 
	 */
	public void borrowerGeoDistribution() throws Exception{
		//借款地域分布
		List<Map<String, Object>> list = financeService.borrowerGeoDistribution();
		int count = 0;
		// 创建一个数值格式化对象
		NumberFormat numberFormat = NumberFormat.getInstance();
		numberFormat.setMaximumFractionDigits(1);
		if(null != list && list.size() > 0){
			for (Map<String, Object> map : list) {
				long temp = (Long) map.get("provinceProportion");
				count = count + (int) temp;
			}
			for (Map<String, Object> map : list) {
				long temp = (Long) map.get("provinceProportion");
				map.put("provinceProportionPercent", numberFormat.format((float)temp/(float)count*100));
			}
		}
		JSONObject obj = new JSONObject();
		obj.put("disList", JSONUtils.toJSONArray(list));
		JSONUtils.printObject(obj);
	}
	/**
	 * 总借款成交金额
	 * @return
	 * @throws Exception 
	 * @throws DataException 
	 */
	public void totalVolumeByMonth() throws Exception{
		//总借款成交金额
		List<Map<String, String>> list = financeService.totalVolumeByMonth();
		JSONObject obj = new JSONObject();
		obj.put("volList", JSONUtils.toJSONArray(list));
		JSONUtils.printObject(obj);
	}
	public FinanceService getFinanceService() {
		return financeService;
	}

	public void setFinanceService(FinanceService financeService) {
		this.financeService = financeService;
	}

	public SelectedService getSelectedService() {
		return selectedService;
	}

	public void setSelectedService(SelectedService selectedService) {
		this.selectedService = selectedService;
	}

	public NewsAndMediaReportService getNewsService() {
		return newsService;
	}

	public void setNewsService(NewsAndMediaReportService newsService) {
		this.newsService = newsService;
	}

	

	public BorrowService getBorrowService() {
		return borrowService;
	}

	public void setBorrowService(BorrowService borrowService) {
		this.borrowService = borrowService;
	}

	public List<Map<String, Object>> getBorrowPurposeList() throws Exception {
		 borrowPurposeList = selectedService
			.borrowPurpose();

		return borrowPurposeList;
	}

	public List<Map<String, Object>> getBorrowDeadlineList() throws Exception {
		  borrowDeadlineList = selectedService
			.borrowDeadline();

		return borrowDeadlineList;
	}

	public List<Map<String, Object>> getBorrowAmountList() throws Exception {
		 borrowAmountList = selectedService.borrowAmountRange();
		return borrowAmountList;
	}

	public void setShoveBorrowTypeService(
			ShoveBorrowTypeService shoveBorrowTypeService) {
		this.shoveBorrowTypeService = shoveBorrowTypeService;
	}

	public void setBorrowMSGMap(List<Map<String, Object>> borrowMSGMap) {
		this.borrowMSGMap = borrowMSGMap;
	}

	public void setBorrowManageService(BorrowManageService borrowManageService) {
		this.borrowManageService = borrowManageService;
	}

	public void setInvestDetailMap(Map<String, String> investDetailMap) {
		this.investDetailMap = investDetailMap;
	}


	public void setBorrowPurposeList(List<Map<String, Object>> borrowPurposeList) {
		this.borrowPurposeList = borrowPurposeList;
	}

	public void setBorrowDeadlineList(List<Map<String, Object>> borrowDeadlineList) {
		this.borrowDeadlineList = borrowDeadlineList;
	}

	public void setBorrowAmountList(List<Map<String, Object>> borrowAmountList) {
		this.borrowAmountList = borrowAmountList;
	}

	public List<Map<String, Object>> getLinksList() {
		return linksList;
	}

	public PublicModelService getPublicModelService() {
		return publicModelService;
	}

	public void setPublicModelService(PublicModelService publicModelService) {
		this.publicModelService = publicModelService;
	}

	public void setLinksList(List<Map<String, Object>> linksList) {
		this.linksList = linksList;
	}

	public List<Map<String, Object>> getMeikuList() {
		return meikuList;
	}

	public void setMeikuList(List<Map<String, Object>> meikuList) {
		this.meikuList = meikuList;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public List<Map<String, Object>> getMeikuStick() {
		return meikuStick;
	}

	public void setMeikuStick(List<Map<String, Object>> meikuStick) {
		this.meikuStick = meikuStick;
	}

	public List<Map<String, Object>> getListsGGList() {
		return listsGGList;
	}

	public void setListsGGList(List<Map<String, Object>> listsGGList) {
		this.listsGGList = listsGGList;
	}

	public List<Map<String, Object>> getBannerList() {
		return bannerList;
	}

	public void setBannerList(List<Map<String, Object>> bannerList) {
		this.bannerList = bannerList;
	}

	public MyHomeService getMyHomeService() {
		return myHomeService;
	}

	public void setMyHomeService(MyHomeService myHomeService) {
		this.myHomeService = myHomeService;
	}

	public HomeInfoSettingService getHomeInfoSettingService() {
		return homeInfoSettingService;
	}

	public void setHomeInfoSettingService(
			HomeInfoSettingService homeInfoSettingService) {
		this.homeInfoSettingService = homeInfoSettingService;
	}

}
